package com.aSemy.qotwReader.core.utils;

/**
 * Methods pertaining to formatting dates.
 * @author Adam Semenenko
 */
public abstract class CalendarUtils
{
    /**
     * Convert elements of a date extracted from a question to a string that can be accepted as an argument by Calibre.
     * 
     * Format from b3ta: 31 Dec 2009
     * Format needed:    31 Decemember 2009
     * 
     * @param dateInt The day of the month as gathered from b3ta.
     * @param monthShort The month from b3ta (is trucated to 3 letters).
     * @param yearInt The year.
     * @return
     */
    public static String getDateString(int dateInt, String monthShort, int yearInt)
    {
        return dateInt + " " + getLongMonth(monthShort) + " " + yearInt;
    }
    
    /**
     * Converts a truncated month (e.g. Jan) to the long version needed by Calibre (e.g. January) to set the metadata.
     * 
     * @param monthShort The truncated month
     * @return The full month name.
     */
    private static String getLongMonth(String monthShort)
    {
        String monthLong;
        if (     monthShort.equalsIgnoreCase("Jan"))
            monthLong = "January";
        else if (monthShort.equalsIgnoreCase("Feb"))
            monthLong = "Febuary";
        else if (monthShort.equalsIgnoreCase("Mar"))
            monthLong = "March";
        else if (monthShort.equalsIgnoreCase("Apr"))
            monthLong = "April";
        else if (monthShort.equalsIgnoreCase("May"))
            monthLong = "May";
        else if (monthShort.equalsIgnoreCase("Jun"))
            monthLong = "June";
        else if (monthShort.equalsIgnoreCase("Jul"))
            monthLong = "July";
        else if (monthShort.equalsIgnoreCase("Aug"))
            monthLong = "August";
        else if (monthShort.equalsIgnoreCase("Oct"))
            monthLong = "October";
        else if (monthShort.equalsIgnoreCase("Nov"))
            monthLong = "November";
        else if (monthShort.equalsIgnoreCase("Sep"))
            monthLong = "September";
        else if (monthShort.equalsIgnoreCase("Dec"))
            monthLong = "December";
        else
            monthLong = "";
        
        return monthLong;
    }
}
